package com.liwang.lanouhn.nvshengo.fragments;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebSettings;
import android.webkit.WebView;

import com.liwang.lanouhn.nvshengo.Info.Info;
import com.liwang.lanouhn.nvshengo.R;

/**
 * Created by lanouhn on 2016/10/12.
 */
public class FeatureFragment extends Fragment {
    private WebView webview;
    public static FeatureFragment newInstants(Info info) {
        FeatureFragment featureFragment = new FeatureFragment();
        Bundle bundle = new Bundle();
        bundle.putSerializable("featureinfo",info);
        featureFragment.setArguments(bundle);
        return featureFragment;
    }
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {

        View view = inflater.inflate(R.layout.fragment_feature,null);
        return view;
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        initView(getView());
        initData();
    }

    private void initView(View view) {
        webview= (WebView) view.findViewById(R.id.webview);
    }

    private void initData() {
        Info infos = (Info) getArguments().getSerializable("featureinfo");
        String url =infos.getUrl();
        WebSettings wSet =webview.getSettings();
        wSet.setJavaScriptEnabled(true);
        webview.loadUrl(url);

    }
}
